
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>总部</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<script src="${pageContext.request.contextPath}/js/MD5.js"></script>
<script src="${pageContext.request.contextPath}/js/city2.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/citySelect2.js"></script>

</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<style>
.main_div {
	min-width: 1000px;
	min-height: 60px
}

.force-overflow1-1 {
	border: none
}

.buttonPic>span {
	color: #FFFFFF;
	font-size: 36px
}

.countyVipCount {
	font-size: 18px;
	line-height: 50px
}

.countyVipCount span {
	color: red
}

.pageChange {
	float: right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">		
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>异业商家管理</span>
					</div>
				</div>
				<form class="form-inline" style="margin-top: 30px;margin-left: 40px">
					<div class="form-group" id="city_4">
						<label style="text-align: right">省市区：</label> <select
							class="form-control" id="prov42" data-code="510000"></select> <select
							class="form-control" id="city42" data-code="-1"></select> <select
							class="form-control" id="area42" data-code="-1"></select>
				    </div>					
					<div class="form-group">
						<label style="margin-left:30px">商家状态：</label>
						<select class="form-control" id="status">
							<option value="-6">请选择</option>
							<option value="0">正常营业</option>
							<option value="1">申请冻结</option>
							<option value="3">申请恢复</option>
						</select>
					</div>
					<div class="form-group">
						<button type="button" onclick="selectinfo()"
							class="btn btn-primary">立即查询</button>
					</div>
				</form>
				<script>
					var selectVal = new CitySelect({
						data : data,
						provId : "#prov42",
						cityId : '#city42',
						areaId : '#area42'
					});
				</script>
				<div class="force-overflow1-1">
					<table class="table table-condensed table-bordered table-hover"
						id="showTable" style="text-align: center">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">序号</th>
							<th style="text-align: center">商家名称</th>
							<th style="text-align: center">商家电话</th>
							<th style="text-align: center">商家所属区域</th>
							<th style="text-align: center">商家状态</th>
							<th style="text-align: center">申请原因</th>
							<th style="text-align: center">操作</th>
							<th style="text-align: center">查看商家</th>
						</tr>
					</table>
					<div class="pageChange">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button class="btn btn-primary" onclick="searchPage()">搜索</button>
					</div>
					<input style="display:none" value="7" id="pageCount"
						name="pageCount" />
				</div>
			</div>
		</section>
	</div>
	<script>
	    $(function(){
	    selectinfo();
	    })
		function nextPage() { //下一页
			var page = $("#pageNum").html();
			if (page < $("#totalpage").html()) {
				page++;
				$("#pageNum").html(page)
				selectinfo();
			}
		}
		function searchPage() { //跳到某一页
			var page = $("#searchInput").val();
			var tatalpage = $("#totalpage").html();
			if (page > tatalpage) {
				page = tatalpage;
				$("#pageNum").html(page)
				$("#searchInput").val(page);
				selectinfo();
			} else {
				if (page <= tatalpage) {
					if (page > 1) {
						$("#pageNum").html(page)
						selectinfo();
					} else {
						page = 1;
						$("#pageNum").html(page)
						selectinfo();
					}
				}
			}
		}
	
		function selectinfo() {
			var pageNum = $("#pageNum").html();
			var pageCount = $("#pageCount").val();
			var status = $("#status").find("option:selected").val();
			var area = $("#area42").find("option:selected").val();
			if (area == -1) {
				area = null
			}
			if (status == -6) {
				status = null
			}
			$.post(urls + "seckillAction/getOtherInfoPage",
				{
					pageNum : pageNum,
					pageCount : pageCount,
					otherStatus : status,
					agentRegion : area
				},
				function(data) {
					//console.log(data)
					if (data) {
						var totalpage = data.totalpage;
						var orderlist = data.list;
						var table = $("#showTable");
						$("#vipCount").html(data.totalVip)
						$("tr").remove(".addtr");
						for (var i = 0; i < orderlist.length; i++) {
							var button;
							var status;
							var button3="<button class='btn btn-primary' onclick='watchDirect(\"" + orderlist[i].id + "\")'>查看直营商家</button>"
							var button1 = "<button class='btn btn-success' onclick='controlSuper(\"" + orderlist[i].id + "\",2)'>冻结商家</button>";
							var button2 = "<button class='btn btn-primary' onclick='controlSuper(\"" + orderlist[i].id + "\",0)'>恢复商家</button>";
							if (orderlist[i].otherStatus == 1) {
								button = button1;
								status = "申请冻结"
							} else if (orderlist[i].otherStatus == 3){
								button = button2;
								status = "申请恢复"
							}else if(orderlist[i].otherStatus == 2){
							button = "-";
							status =  "已冻结";	
							orderlist[i].remark="-";						
							}
							else if(orderlist[i].otherStatus == 5){
							button = "-";
							status =  "申请开店";
							orderlist[i].remark="-";
							}
						else if(orderlist[i].otherStatus == 0){
							button = "-";
							status =  "正常营业";
							orderlist[i].remark="-";
							}
							var append = "<tr class='addtr'><td>" + (i + 1) + "</td>" +
								"<td >" + orderlist[i].otherPrincipal + "</td>" +
								"<td>" + orderlist[i].otherPhone + "</td>" +
								"<td>" + orderlist[i].otherName + "</td>" +
							
								"<td>" + status + "</td>" +
								"<td>" + orderlist[i].remark + "</td>" +
								"<td>" + button + "</td>"+
									"<td>" + button3 + "</td></tr>";
							table.append(append);
						}
						$("#totalpage").html(totalpage);
					}
				}
				, "json"
			)
		}
		function controlSuper(id, status) {
			if (confirm("是否继续操作？")) {
				$.post(urls + "agentAction/updateOtherInfo",
					{
						id : id,
						otherStatus : status
					},
					function(res) {
						if (res==true) {
							selectinfo()
						} else {
							alert("操作失败")
						}
					}
				)
			}
		}
		function watchDirect(id){
		 location.href = "${pageContext.request.contextPath}/YMGback/head/watchOther.jsp?id="+id
		}
	</script>
</body>
</html>